﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.Composition;
using WaterRevenueMS.Componnent.Common;

using WaterRevenueMS.Componnent.Entities.BasicSet;
using WaterRevenueMS.Core.Repository.BasicSet;
using WaterRevenueMS.Domain.ViewModels.BasicSet;
using WaterRevenueMS.Domain.ViewModels.BasicSet.BankCode;

namespace WaterRevenueMS.Core.Service.BasicSet.Impl
{
    [Export(typeof(IBankCodeService))]
    public class BankCodeService : CoreServiceBase, IBankCodeService
    {
        #region 属性
        [Import]
        public IBankCodeRepository BankCodeRepository { get; set; }

        public IQueryable<BankCode> BankCodeS
        {
            get { return BankCodeRepository.Entities; }
        }

        #endregion

        #region 公共方法

        public OperationResult Insert(BankCodeModel BankCode)
        {
            var entity = new BankCode
            {
                Id= BankCode.Id,
                Yin_HMC = BankCode.Yin_HMC,
                Yin_HJC = BankCode.Yin_HJC,
                CreateDT = DateTime.Now,
                ReviseDT = DateTime.Now
                
            };
            BankCodeRepository.Insert(entity);
            return new OperationResult(OperationResultType.Success, "添加成功");
        }

        public OperationResult Update(BankCodeModel BankCode)
        {
            var entity = new BankCode
            {
                Id = BankCode.Id,
                Yin_HMC = BankCode.Yin_HMC,
                Yin_HJC = BankCode.Yin_HJC,

                ReviseDT = DateTime.Now

            };
            BankCodeRepository.Update(entity);
            return new OperationResult(OperationResultType.Success, "更新成功");
        }

        public OperationResult Delete(int Id)
        {
            var BankCode = BankCodeS.FirstOrDefault(t => t.Id == Id);
            BankCode.IsDeleted = true;

            BankCodeRepository.Update(BankCode);
            return new OperationResult(OperationResultType.Success, "删除成功");
        }

        #endregion


    }
}
